﻿using System;

namespace UnitTests
{
    /// <summary>
    /// Just a dummy class that raises different kind of events.
    /// </summary>
    public class SomeClassThatRaisesEvents
    {
        /// <summary>
        /// Just a dummy event handler.
        /// </summary>
        public delegate void MyCustomEventHandler(object sender, MyCustomEventArgs e);

        /// <summary>
        /// Just a dummy event handler.
        /// </summary>
        public delegate void MyAnotherCustomEventHandler(int x, int y);

        /// <summary>
        /// Just a dummy event handler.
        /// </summary>
        public delegate void MyThirdCustomEventHandler();

        /// <summary>
        /// Just a dummy EventArgs class.
        /// </summary>
        public sealed class MyCustomEventArgs : EventArgs
        {
            public string Message { set; get; }
        }

        public event EventHandler Event1;
        public event MyCustomEventHandler Event2;
        public event MyAnotherCustomEventHandler Event3;
        public event MyThirdCustomEventHandler Event4;

        /// <summary>
        /// This method raises four events. 
        /// </summary>
        public void RaiseFourEvents()
        {
            OnEvent1(EventArgs.Empty);
            OnEvent2(new MyCustomEventArgs { Message = "Hello Unit Test!" });
            OnEvent3(123, 456);
            OnEvent4();
        }

        /// <summary>
        /// Raises the Event1 event.
        /// </summary>
        protected virtual void OnEvent1(EventArgs e)
        {
            if (Event1 != null)
            {
                Event1(this, e);
            }
        }

        /// <summary>
        /// Raises the Event2 event.
        /// </summary>
        protected virtual void OnEvent2(MyCustomEventArgs e)
        {
            if (Event2 != null)
            {
                Event2(this, e);
            }
        }

        /// <summary>
        /// Raises the Event3 event.
        /// </summary>
        protected virtual void OnEvent3(int x, int y)
        {
            if (Event3 != null)
            {
                Event3(x, y);
            }
        }

        /// <summary>
        /// Raises the Event4 event.
        /// </summary>
        protected virtual void OnEvent4()
        {
            if (Event4 != null)
            {
                Event4();
            }
        }
    }
}